// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var router = require("../hash/pageRouter");
	var _css = require("./wareHouseDetail.css");
	var databind = require("databind");
	var tools = require("tools");
	var caseNumber;
	var financeNumber;
	var init = function(page) {
		router.init();
		caseNumber = page.params.caseNumber;
		financeNumber = page.params.financeNumber;
		initEvent();
	};
	var initEvent = function() {
		searchInboundInfoForFinanceDetail(caseNumber);
//		searchInboundInfoForFinanceDetail("R-ahbb001-1705250001");
	};

	//从仓储系统查询入库详情信息
	var searchInboundInfoForFinanceDetail = function(inboundNo) {
		base.fnAjax({
			action: "searchInboundInfoForFinanceDetail.json",
			oData: {
				inboundNo: inboundNo
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					data.datas[0].result.financeNumber = financeNumber;
					databind.fillForm($("#wareHouseDetail"), data.datas[0].result);
					//入库明细表
					$.each(data.datas[0].result.photofile.split(','), function(){
						var _this = this;
						var str = '<a target="_blank" href="'+_this+'"><img src="'+_this+'"></a>'
						$("#wareHouseDetail .goodsFile").append(str);
					});
					
					//磅单
					$.each(data.datas[0].result.poundfile.split(','), function(){
						var _this = this;
						var str = '<a target="_blank" href="'+_this+'"><img src="'+_this+'"></a>'
						$("#wareHouseDetail .poundFile").append(str);
					});
					
					//检验单
					$.each(data.datas[0].result.inspectionsheet_photos.split(','), function(){
						var _this = this;
						var str = '<a target="_blank" href="'+_this+'"><img src="'+_this+'"></a>'
						$("#wareHouseDetail .inspectionsheet_photos").append(str);
					});
					
					//货物图片
					$.each(data.datas[0].result.cargo_photos.split(','), function(){
						var _this = this;
						var str = '<a target="_blank" href="'+_this+'"><img src="'+_this+'"></a>'
						$("#wareHouseDetail .cargo_photos").append(str);
					});
				} else {
					base.alert(2, data.message);
				}
			}
		});
	}
	
	return {
		init: init
	};

});